package com.sunda.spmsoversea.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sunda.spmsoversea.entity.OverseaWhsDumpDtl;
import com.sunda.spmsoversea.mapper.OverseaWhsDumpDtlMapper;
import com.sunda.spmsoversea.service.IOverseaWhsDumpDtlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 海外转储任务明细表 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-11-02
 */
@Service
public class OverseaWhsDumpDtlServiceImpl extends ServiceImpl<OverseaWhsDumpDtlMapper, OverseaWhsDumpDtl> implements IOverseaWhsDumpDtlService {

    @Override
    public List<Map<String, Object>> getWhsDumpDtlList(String whsDumpUuid) {
        if (StringUtils.isEmpty(whsDumpUuid)){
            return null;
        }
        return this.baseMapper.getWhsDumpDtlList(whsDumpUuid);
    }

    @Override
    public int deleteWhsDumpDtl(String whsDumpUuid, Integer item) {
        if (StringUtils.isNotEmpty(whsDumpUuid) && item != null){
            QueryWrapper<OverseaWhsDumpDtl> queryWrapper =
                    new QueryWrapper<OverseaWhsDumpDtl>().eq("WHS_DUMP_UUID", whsDumpUuid).eq("ITEM", item);
            return this.baseMapper.delete(queryWrapper);
        }
        return 0;
    }
}
